package com.aspose.cells;

class zbvs extends zbz {
   zbvs() {
      this.c(224);
      this.b(20);
      this.c = new byte[20];
      this.a();
   }

   void a() {
      com.aspose.cells.b.a.za.a((byte[])this.c, 0, this.c.length);
      this.c[4] = -11;
      this.c[5] = -1;
      this.c[6] = 32;
      this.c[9] = -8;
      this.c[18] = -64;
      this.c[19] = 32;
   }

   void a(int var1) {
      if ((var1 & '\uffff') != 0) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, this.c, 0, 2);
      }

   }

   int a(Style var1, boolean[] var2) {
      var2[0] = true;
      if (var1.getPattern() == 0) {
         return 64;
      } else {
         return var1.getPattern() == 1 ? var1.b.b(var1.e(), 65, var2) : var1.b.b(var1.e(), 64, var2);
      }
   }

   int b(Style var1, boolean[] var2) {
      var2[0] = true;
      switch(var1.getPattern()) {
      case 0:
         return 65;
      case 1:
         return 64;
      default:
         return var1.a.b(var1.e(), 65, var2);
      }
   }

   int a(Style var1, zakp var2, boolean[] var3) {
      var3[0] = true;
      return var2.b(var1.e(), 64, var3);
   }

   zbvr a(Style var1, int var2) {
      zbvr var3 = new zbvr();
      if (var1.g()) {
         this.c[9] = var1.i();
      } else {
         this.c[9] = (byte)(~(var1.i() & 255) & 252);
      }

      if (var1.g()) {
         this.c[4] = 1;
         this.c[5] = 0;
         if (var1.h() != 0) {
            int var4 = (var1.h() << 4) + 1;
            if ((var4 & '\uffff') != 65521) {
               System.arraycopy(com.aspose.cells.b.a.zc.a(var4), 0, this.c, 4, 2);
            }
         }
      } else {
         this.c[4] = -11;
         this.c[5] = -1;
      }

      boolean var9 = false;
      boolean[] var6;
      int var7;
      int var10;
      if (var1.isGradient()) {
         byte var5 = 1;
         var10 = var5 << 2;
         this.c[17] = (byte)var10;
         var6 = new boolean[]{var9};
         var7 = this.a(var1, var6);
         var9 = var6[0];
         if (!var9) {
            var3.a(4, var1.b);
         }

         this.c[18] = (byte)(this.c[18] & 128);
         this.c[18] |= (byte)var7;
         GradientFill var8 = new GradientFill((Object)null, (Workbook)null);
         var8.a(3, var1.b, 0.0D, var1.a, var1.v(), var1.w());
         var3.a(6, var8);
      } else {
         if (!com.aspose.cells.a.c.zh.a(var1.getBackgroundColor()) && var1.getPattern() != 0) {
            boolean[] var11 = new boolean[]{var9};
            int var12 = this.b(var1, var11);
            var9 = var11[0];
            if (!var9) {
               var3.a(5, var1.a);
            }

            if (var12 != -1) {
               var7 = var1.getPattern();
               var7 <<= 2;
               this.c[17] = (byte)var7;
               var7 = var12 & 1;
               if (var7 == 1) {
                  this.c[18] = (byte)(this.c[18] | 128);
               } else {
                  this.c[18] = (byte)(this.c[18] & 127);
               }

               var7 = var12 >> 1;
               this.c[19] = (byte)var7;
            }
         }

         if (var1.getPattern() != 0) {
            var10 = var1.getPattern();
            var10 <<= 2;
            this.c[17] = (byte)var10;
            var6 = new boolean[]{var9};
            var7 = this.a(var1, var6);
            var9 = var6[0];
            if (!var9) {
               var3.a(4, var1.b);
            }

            this.c[18] = (byte)(this.c[18] & 128);
            this.c[18] |= (byte)var7;
         }
      }

      if (var1.u()) {
         this.c[19] = (byte)(this.c[19] | 64);
      }

      this.a(var1, var3);
      this.a(var1);
      this.b(var1);
      this.c(var1);
      if (var1.getTextDirection() != 0) {
         if (var1.getTextDirection() == 1) {
            this.c[8] = (byte)(this.c[8] | 64);
         } else {
            this.c[8] = (byte)(this.c[8] | 128);
         }
      }

      if (var1.r() != -1) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1.r()), 0, this.c, 2, 2);
      }

      if (var1.isTextWrapped()) {
         this.c[6] = (byte)(this.c[6] | 8);
      }

      if (var1.getRotationAngle() >= 0) {
         this.c[7] = (byte)var1.getRotationAngle();
      } else {
         this.c[7] = (byte)(90 - var1.getRotationAngle());
      }

      if (!var1.isLocked()) {
         this.c[4] = (byte)(this.c[4] & 254);
      }

      if (var1.isFormulaHidden()) {
         this.c[4] = (byte)(this.c[4] | 2);
      }

      if (var1.t()) {
         this.c[4] = (byte)(this.c[4] | 8);
      }

      if (var1.getShrinkToFit()) {
         this.c[8] = (byte)(this.c[8] | 16);
      }

      if (var1.getIndentLevel() != 0) {
         this.c[8] = (byte)(this.c[8] & 240);
         if (var1.getIndentLevel() > 15) {
            this.c[8] = (byte)(this.c[8] | 15);
            var3.a(15, (short)var1.getIndentLevel());
         } else {
            this.c[8] |= (byte)var1.getIndentLevel();
         }
      }

      this.c[17] = (byte)(this.c[17] | 2);
      return var3;
   }

   private void a(Style var1, zbvr var2) {
      boolean var4 = true;
      boolean var5 = false;
      zakp var6 = var1.getBorders().getByBorderType(1).a;
      int var7 = var1.getBorders().getByBorderType(1).getLineStyle();
      boolean[] var8;
      int var9;
      if (var7 != 0) {
         var8 = new boolean[]{var5};
         var9 = this.a(var1, var6, var8);
         var5 = var8[0];
         if (!var5) {
            var2.a(9, var6);
         }

         this.c[12] |= (byte)var9;
      }

      var6 = var1.getBorders().getByBorderType(2).a;
      var7 = var1.getBorders().getByBorderType(2).getLineStyle();
      int var3;
      if (var7 != 0) {
         var8 = new boolean[]{var5};
         var9 = this.a(var1, var6, var8);
         var5 = var8[0];
         if (!var5) {
            var2.a(10, var6);
         }

         var3 = var9 & 1;
         var9 >>= 1;
         if (var3 == 0) {
            this.c[12] = (byte)(this.c[12] & 127);
         } else {
            this.c[12] = (byte)(this.c[12] | 128);
         }

         this.c[13] |= (byte)var9;
      }

      var6 = var1.getBorders().getByBorderType(4).a;
      var7 = var1.getBorders().getByBorderType(4).getLineStyle();
      if (var7 != 0) {
         var8 = new boolean[]{var5};
         var9 = this.a(var1, var6, var8);
         var5 = var8[0];
         if (!var5) {
            var2.a(7, var6);
         }

         this.c[14] |= (byte)var9;
      }

      var6 = var1.getBorders().getByBorderType(8).a;
      var7 = var1.getBorders().getByBorderType(8).getLineStyle();
      if (var7 != 0) {
         var8 = new boolean[]{var5};
         var9 = this.a(var1, var6, var8);
         var5 = var8[0];
         if (!var5) {
            var2.a(8, var6);
         }

         var3 = var9 & 1;
         if (var3 == 0) {
            this.c[14] = (byte)(this.c[14] & 127);
         } else {
            this.c[14] = (byte)(this.c[14] | 128);
         }

         var9 >>= 1;
         this.c[15] |= (byte)var9;
      }

      var6 = var1.getBorders().e();
      var7 = var1.getBorders().getDiagonalStyle();
      if (var7 != 0) {
         var8 = new boolean[]{var5};
         var9 = this.a(var1, var6, var8);
         var5 = var8[0];
         if (!var5) {
            var2.a(11, var6);
         }

         var3 = var9 & 3;
         if (var3 != 0) {
            this.c[15] |= (byte)(var3 << 6);
         }

         var3 = var9 & '￼';
         this.c[16] |= (byte)(var3 >> 2);
      }

   }

   private void a(Style var1) {
      BorderCollection var3 = var1.getBorders();
      int var2 = var3.getByBorderType(1).getLineStyle();
      if (var2 != 0) {
         this.c[10] |= (byte)var2;
      }

      var2 = var3.getByBorderType(2).getLineStyle();
      if (var2 != 0) {
         this.c[10] |= (byte)((byte)var2 << 4);
      }

      var2 = var3.getByBorderType(4).getLineStyle();
      if (var2 != 0) {
         this.c[11] |= (byte)var2;
      }

      var2 = var3.getByBorderType(8).getLineStyle();
      if (var2 != 0) {
         this.c[11] |= (byte)((byte)var2 << 4);
      }

      var2 = var1.getBorders().getDiagonalStyle();
      if (var2 != 0) {
         int var4 = (byte)var2 << 5;
         this.c[16] |= (byte)var4;
         var4 &= 256;
         if (var4 == 0) {
            this.c[17] = (byte)(this.c[17] & 254);
         } else {
            this.c[17] = (byte)(this.c[17] | 1);
         }

         this.c[13] |= (byte)((var1.getBorders().f() & 255) << 6);
      }

   }

   private void b(Style var1) {
      switch(var1.getHorizontalAlignment()) {
      case 1:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 2);
         break;
      case 2:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 6);
         break;
      case 3:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 7);
         break;
      case 4:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 4);
         break;
      case 5:
         this.c[6] = (byte)(this.c[6] & 248);
         break;
      case 6:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 5);
         break;
      case 7:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 1);
         break;
      case 8:
         this.c[6] = (byte)(this.c[6] & 248);
         this.c[6] = (byte)(this.c[6] | 3);
         break;
      default:
         return;
      }

   }

   private void c(Style var1) {
      switch(var1.getVerticalAlignment()) {
      case 0:
         this.c[6] = (byte)(this.c[6] & 143);
         this.c[6] = (byte)(this.c[6] | 32);
         break;
      case 1:
         this.c[6] = (byte)(this.c[6] & 143);
         this.c[6] = (byte)(this.c[6] | 16);
      case 2:
      case 4:
      case 5:
      case 7:
      case 8:
      default:
         break;
      case 3:
         this.c[6] = (byte)(this.c[6] & 143);
         this.c[6] = (byte)(this.c[6] | 64);
         break;
      case 6:
         this.c[6] = (byte)(this.c[6] & 143);
         this.c[6] = (byte)(this.c[6] | 48);
         break;
      case 9:
         this.c[6] = (byte)(this.c[6] & 143);
      }

   }
}
